package com.community.owner.controller;

import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.owner.domain.vo.StorageRoomVo;
import com.community.owner.service.StorageRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 储藏室信息Controller
 */
@RestController
@RequestMapping("/storageRoom")
public class OwnerStorageRoomController extends BaseController {

    @Autowired
    private StorageRoomService storageRoomService;

    /**
     * 根据业主ID获取储藏室列表
     */
    @GetMapping("/getStorageRoomByOwnerId/{ownerId}")
    public AjaxResult getStorageRoomByOwnerId(@PathVariable Long ownerId) {
        try {
            List<StorageRoomVo> storageRooms = storageRoomService.getStorageRoomByOwnerId(ownerId);
            return AjaxResult.success(storageRooms);
        } catch (Exception e) {
            logger.error("获取储藏室信息失败", e);
            return AjaxResult.error("获取储藏室信息失败");
        }
    }
}
